package com.InfinityRun;

import android.util.Log;
import Objects.Vector2;

public class SceneManager 
{
	private static SceneManager instance = null;
	boolean isEscape;
	Vector2 screen;
	Scene actualScene;
	
	private SceneManager(boolean isEscape, int x, int y)
	{
		this.isEscape = isEscape;
		screen = new Vector2(x,y);
		
		if(this.isEscape)
		{
			actualScene = new InstructionsScene();
			
		}
		else
		{
			actualScene = new MenuScene((int)screen.x,(int)screen.y);
		}
	}
	
	public static SceneManager getInstance(boolean isEscape, int x, int y)
	{
		if(instance == null)
			instance = new SceneManager(isEscape,x,y);
		
		return instance;
	}
	
 	public static SceneManager getInstance()
	{		
		return instance;
	}

	public void ChangeScene(int id)
	{
		Scene s = null;
		
		if(isEscape)
		{
			switch(id)
			{
				case 2:
					s = new GameScene((int)screen.x,(int)screen.y);
					break;
					
				case 3:
					Log.d("testes", "testes");
					MainGame.GoToEscape(actualScene.win);
					break;
					
				default:
					s = new GameScene((int)screen.x,(int)screen.y);
					break;
			}
		}
		
		else
		{
			switch(id)
			{
				case 0:
					s = new MenuScene((int)screen.x,(int)screen.y);
					break;
					
				case 1:
					s = new InstructionsScene();
					break;
					
				case 2:
					s = new GameScene((int)screen.x,(int)screen.y);
					break;
					
				case 3:
					s = new LoseScene();
					break;
					
				case 4:
					//s = new VictoryScene();
					break;
					
				default:
					s = new GameScene((int)screen.x,(int)screen.y);
					break;
			}
		}
		
		if(s != null)
			actualScene = s;
	}
	
	public void Destroy()
	{
		instance = null;
	}
}
